/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package struts.impl;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import struts.StrutsAction;
import struts.StrutsForm;
import struts.StrutsPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Action</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link struts.impl.StrutsActionImpl#isUnknown <em>Unknown</em>}</li>
 *   <li>{@link struts.impl.StrutsActionImpl#isValidate <em>Validate</em>}</li>
 *   <li>{@link struts.impl.StrutsActionImpl#getUsedForm <em>Used Form</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class StrutsActionImpl extends DynamicResourceImpl implements StrutsAction {
	/**
	 * The default value of the '{@link #isUnknown() <em>Unknown</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isUnknown()
	 * @generated
	 * @ordered
	 */
	protected static final boolean UNKNOWN_EDEFAULT = false;

	/**
	 * The cached value of the '{@link #isUnknown() <em>Unknown</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isUnknown()
	 * @generated
	 * @ordered
	 */
	protected boolean unknown = UNKNOWN_EDEFAULT;

	/**
	 * The default value of the '{@link #isValidate() <em>Validate</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isValidate()
	 * @generated
	 * @ordered
	 */
	protected static final boolean VALIDATE_EDEFAULT = false;

	/**
	 * The cached value of the '{@link #isValidate() <em>Validate</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isValidate()
	 * @generated
	 * @ordered
	 */
	protected boolean validate = VALIDATE_EDEFAULT;

	/**
	 * The cached value of the '{@link #getUsedForm() <em>Used Form</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getUsedForm()
	 * @generated
	 * @ordered
	 */
	protected StrutsForm usedForm;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected StrutsActionImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EClass eStaticClass() {
		return StrutsPackage.Literals.STRUTS_ACTION;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isUnknown() {
		return unknown;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setUnknown(boolean newUnknown) {
		boolean oldUnknown = unknown;
		unknown = newUnknown;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, StrutsPackage.STRUTS_ACTION__UNKNOWN, oldUnknown, unknown));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isValidate() {
		return validate;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setValidate(boolean newValidate) {
		boolean oldValidate = validate;
		validate = newValidate;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, StrutsPackage.STRUTS_ACTION__VALIDATE, oldValidate, validate));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public StrutsForm getUsedForm() {
		if (usedForm != null && usedForm.eIsProxy()) {
			InternalEObject oldUsedForm = (InternalEObject)usedForm;
			usedForm = (StrutsForm)eResolveProxy(oldUsedForm);
			if (usedForm != oldUsedForm) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, StrutsPackage.STRUTS_ACTION__USED_FORM, oldUsedForm, usedForm));
			}
		}
		return usedForm;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public StrutsForm basicGetUsedForm() {
		return usedForm;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setUsedForm(StrutsForm newUsedForm) {
		StrutsForm oldUsedForm = usedForm;
		usedForm = newUsedForm;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, StrutsPackage.STRUTS_ACTION__USED_FORM, oldUsedForm, usedForm));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case StrutsPackage.STRUTS_ACTION__UNKNOWN:
				return isUnknown() ? Boolean.TRUE : Boolean.FALSE;
			case StrutsPackage.STRUTS_ACTION__VALIDATE:
				return isValidate() ? Boolean.TRUE : Boolean.FALSE;
			case StrutsPackage.STRUTS_ACTION__USED_FORM:
				if (resolve) return getUsedForm();
				return basicGetUsedForm();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case StrutsPackage.STRUTS_ACTION__UNKNOWN:
				setUnknown(((Boolean)newValue).booleanValue());
				return;
			case StrutsPackage.STRUTS_ACTION__VALIDATE:
				setValidate(((Boolean)newValue).booleanValue());
				return;
			case StrutsPackage.STRUTS_ACTION__USED_FORM:
				setUsedForm((StrutsForm)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void eUnset(int featureID) {
		switch (featureID) {
			case StrutsPackage.STRUTS_ACTION__UNKNOWN:
				setUnknown(UNKNOWN_EDEFAULT);
				return;
			case StrutsPackage.STRUTS_ACTION__VALIDATE:
				setValidate(VALIDATE_EDEFAULT);
				return;
			case StrutsPackage.STRUTS_ACTION__USED_FORM:
				setUsedForm((StrutsForm)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case StrutsPackage.STRUTS_ACTION__UNKNOWN:
				return unknown != UNKNOWN_EDEFAULT;
			case StrutsPackage.STRUTS_ACTION__VALIDATE:
				return validate != VALIDATE_EDEFAULT;
			case StrutsPackage.STRUTS_ACTION__USED_FORM:
				return usedForm != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (unknown: ");
		result.append(unknown);
		result.append(", validate: ");
		result.append(validate);
		result.append(')');
		return result.toString();
	}

} //StrutsActionImpl
